package com.ysxsoft.wdg.util;

import android.content.Context;
import android.graphics.Bitmap;

import com.nanchen.compresshelper.CompressHelper;
import com.ysxsoft.wdg.constant.MCConfig;

import java.io.File;

/**
 * create by Sincerly on 2018/12/18 0018
 **/
public class ImageUtils {
    public static String compress(Context context,String name, File oldFile) {
        String path = "";
        File newFile = new CompressHelper.Builder(context)
                .setQuality(80)    // 默认压缩质量为80
                .setFileName(name) // 设置你需要修改的文件名
                .setCompressFormat(Bitmap.CompressFormat.JPEG) // 设置默认压缩为jpg格式
                .setDestinationDirectoryPath(MCConfig.PICTURE_DIR)
                .build()
                .compressToFile(oldFile);
        path = newFile.getPath();
        return path;
    }
}
